package com.cwt_taxi_xa.data;

import com.cwt_taxi_xa.util.CompareUtil;

public class SocketConfig {
    private String ip;
    private String port;
    private boolean open = false;

    public SocketConfig(String ip, String port, boolean open) {
        this.ip = ip;
        this.port = port;
        this.open = open;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public boolean isOpen() {
        return open;
    }

    public void setOpen(boolean open) {
        this.open = open;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj != null){
            SocketConfig config = (SocketConfig)obj;
            if(!CompareUtil.equals(getIp(),config.getIp())){
                return false;
            }else if(!CompareUtil.equals(getPort(),config.getPort())){
                return false;
            }else if(!isOpen() == config.isOpen()){
                return false;
            }
        }else{
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "SocketConfig{" +
                "ip='" + ip + '\'' +
                ", port='" + port + '\'' +
                ", open=" + open +
                '}';
    }
}
